<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
    <script>
        let set1 = new Set([1, 2, 3, 4, 5, "张三丰", undefined, null, 1, 2, 3, 4, 5]);
        console.log(set1);
        //我们可以使用set数据结构 给数组去重
        let arr = [1, 2, 5, 3, 4, 1, 3, 2, 7, 6, 4, 5, 9, 0];
        let set2 = new Set(arr);
        console.log(set2);
        //set是一种伪数组  因此 我们可以利用数组的from方法 将伪数组转换为真数组
        let arr1 = Array.from(set2);
        console.log(arr1);
        //set数据的相关属性 和 方法
        let set = new Set([1, 2, 3, 4, 5]);
        //size
        console.log(set.size);//5
        //add
        let set4 = set.add(6);
        console.log(set4);
        console.log(set);
         //delete
         let ret = set4.delete(6);
        console.log(set4,ret);
        let ret1 = set4.delete(7);//set数据中 没有7成员 因此无法成功删除
        console.log(set4,ret1);

        //has
        console.log(set4.has(8));//false
        console.log(set4.has(5));//true

        set4.clear();
        console.log(set4);
    </script>
</body>

</html>